<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * 获取输入数据
 * @param $nameArray array 名称数组
 * @return array 输入数据的数组
 */
function getInputData($nameArray)
{
    $data = [];
    foreach ($nameArray as $name) {
        $data[$name] = input($name);
    }
    return $data;
}

/**
 * 验证数据
 * @param $data array 数据
 * @param $validateName string 验证器名称
 * @param $sceneName string 场景名称
 * @return array|bool 错误信息|验证通过
 */
function validateData($data, $validateName, $sceneName)
{
    $validate = validate($validateName);
    if (!$validate->scene($sceneName)->check($data)) {
        return $validate->getError();
    } else {
        return true;
    }
}
